<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>导航页面</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      #container {
        width: 100%;
        height: 100vh;
      }

    </style>

    <script type="text/javascript">
      window._AMapSecurityConfig = {
        securityJsCode: "74e0004f836a54f2b9b0efab467e90ef",
      };

    </script>
    <script
            type="text/javascript"
            src="https://webapi.amap.com/maps?v=1.4.15&key=f3fa39a7385d7771d262a3da55b1d475"
    ></script>
</head>
<body>
<div id="container"></div>

<script>
      var map = new AMap.Map("container", {
        zoom: 15, // 默认缩放级别
        center: [111.707896, 35.739925], // 默认中心点坐标
      });
      window.onload = function () {
        if (window.shenling) {
          shenling.getLocation("getLocation");
        }
      };
      function getLocation(lon, lat) {
        // 将坐标定位到对应的经纬度上
        map.setZoomAndCenter(18, [lon, lat]);
        map.plugin(["AMap.PlaceSearch"], function () {
          // 构造PlaceSearch类
          var MSearch = new AMap.PlaceSearch({
            pageSize: 4,
            pageIndex: 1,
            extensions: "base", // 返回信息详略，默认为base（基本信息）
          });
          // 搜索返回结果
          AMap.event.addListener(MSearch, "complete", (result) => {
            shenling.receiveData(
              "search_list",
              JSON.stringify(result?.poiList?.pois || [])
            );
          });
          MSearch.searchNearBy("地点", new AMap.LngLat(lon, lat)); //关键字查询
        });
      }

</script>
</body>
</html>
